Skip to content

Add buy it now price to auctions - #7

Open
Rigidity wants to merge 2 commits into
mainfrom
rigidity/buy-it-now-feature
Open

Rigidity wants to merge 2 commits into
mainfrom
rigidity/buy-it-now-feature

Conversation

@Rigidity

@Rigidity Rigidity commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Adds an optional buy now price to auctions. A bid at exactly that price wins outright, and the auction can be ended in the same spend instead of waiting for the end time.

Puzzles

No new action. BUY_NOW_PRICE (0 means there isn't one) is curried into the existing bid and end actions.

  • bid_action.rue (hash d94e4389be5a2d7f9fd692c792a78f184c8e1f70ec633873b22744f2d0233e9c): bids can't exceed the buy now price. A bid at exactly the price skips the bid verifier, so the increment can't make the price unreachable once there's a bid close to it. It must still be strictly higher than the winning bid and placed before the end time (or within the grace period).
  • end_action.rue (hash 5d9df3e170a0ee659f54372537dd49fd11973aaca297eb9b855b048e79b7f21b): if the winning bid equals the buy now price (and the price is nonzero), the end time and grace period assertions are skipped, since that bid can never be outbid. Payouts are unchanged.

The bid and end puzzle hashes change for every auction, including auctions without a buy now price.

Driver

  • AuctionSettings::buy_now_price: Option<u64>, appended to the settings, so the launcher memo layout changes (the memo version stays 0).
  • AuctionInfo::available_buy_now_price: the price while the auction can still be bought.
  • AuctionExt::spend_buy_now_actions(ctx, puzzle_hash, grace, nft): returns the bid at the buy now price, the bid and end action spends, and the NFT unlocked to the buyer (to the bid placed in the same spend, not the auction's current winning bid). It returns AuctionError::BuyNowUnavailable if the auction can't be bought now.
  • Validation rejects a buy now price of 0 (ZeroBuyNowPrice) and a price below the minimum bid (BuyNowPriceBelowMinimumBid).

The README has a new Buy Now section, and covers it in the life cycle, customization and validation sections.

Tests

tests/buy_now.rs:

  • Buying now ends the auction right away and pays everyone (XCH, CAT and revocable CAT reserves), and the auction can't be bid on, ended, cancelled or bought again.
  • Buying now refunds the winning bid, including bids placed earlier in the same spend (all three reserve kinds).
  • A bid at the price skips the flat and percent verifiers; a price equal to the minimum bid works; bids above the price are rejected by the driver and on chain.
  • A bid at the price placed on its own lets anyone end the auction right away.
  • Below the price, and without a buy now price, the end time and grace period still apply.
  • Buying follows bid timing, including the grace period.
  • Memo round trip, cancel before a buy now, and the driver refusing to buy when it's unavailable.

tests/validation.rs and tests/parsing.rs cover the new validation errors at launch and when parsing a memo.

Decisions for review

  • Buy now stays available while the winning bid is below the price, rather than disappearing after the first bid.
  • Bids above the price are rejected, so a bid at the price is final and a pending buy now can't be displaced by mempool replacement. The alternative is to allow higher bids, which would also end the auction early.
  • The memo version stays 0 even though the layout changed, since the project is pre-release. The alternative is bumping it to 1.
  • spend_buy_now_actions returns AuctionError (with a typed BuyNowUnavailable variant), unlike the other AuctionExt methods, which return DriverError. The alternative is a DriverError::Custom string error, which callers can't match on.

- Return AuctionError::BuyNowUnavailable from spend_buy_now_actions instead of a custom driver error
- Make the NFT unlock for a same-spend winning bid private
- Build the bid and end action curry args in one place each
- Cover CAT reserves for refunds in a buy now spend, both bid verifiers, and the minimum bid boundary
- Move buy now validation tests to tests/validation.rs and add a parsing case
- Share the harness's bid loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant